package com.tubi.ArrayList;

import com.tubi.domain.Student;

import java.util.ArrayList;
import java.util.Scanner;

public class ArrayLIst筛选 {
    public static void main(String[] args) {

        ArrayList<Student> list = new ArrayList();
        Student s = new Student("rong", 12);
        Student s2 = new Student("ron2g", 122);
        Student s3 = new Student("ron2g", 1232);
        Student s1 = new Student("rong2", 2);
        list.add(s);
        list.add(s1);
        list.add(s3);
        list.add(s2);


        ArrayList<Student> gli = getlist(list);
        for (int i = 0; i < gli.size(); i++) {
            System.out.println(gli.get(i).getName()+"-----"+gli.get(i).getAge());
        }
    }
    public static ArrayList<Student> getlist(ArrayList<Student> list){
        ArrayList<Student> listnew = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
            Student st = list.get(i);
            if(st.getAge()<18){
                listnew.add(st);
            }
        }
        return listnew;
    }
}
